template(name="cronSettings")
  ul#cron-setting.setting-detail
    li
      h3 {{_ 'cron-migrations'}}
      .form-group
        label {{_ 'migration-status'}}
        .status-indicator
          span.status-label {{_ 'status'}}:
          span.status-value {{migrationStatus}}
        .progress-section
          .progress
            .progress-bar(role="progressbar" style="width: {{migrationProgress}}%" aria-valuenow="{{migrationProgress}}" aria-valuemin="0" aria-valuemax="100") 
              | {{migrationProgress}}%
          .progress-text
            | {{migrationProgress}}% {{_ 'complete'}}
      
      .form-group
        button.js-start-all-migrations.btn.btn-primary {{_ 'start-all-migrations'}}
        button.js-pause-all-migrations.btn.btn-warning {{_ 'pause-all-migrations'}}
        button.js-stop-all-migrations.btn.btn-danger {{_ 'stop-all-migrations'}}
    
    li
      h3 {{_ 'board-operations'}}
      .form-group
        label {{_ 'scheduled-board-operations'}}
        button.js-schedule-board-cleanup.btn.btn-primary {{_ 'schedule-board-cleanup'}}
        button.js-schedule-board-archive.btn.btn-warning {{_ 'schedule-board-archive'}}
        button.js-schedule-board-backup.btn.btn-info {{_ 'schedule-board-backup'}}
    
    li
      h3 {{_ 'cron-jobs'}}
      .form-group
        label {{_ 'active-cron-jobs'}}
        each cronJobs
          .job-item
            .job-info
              .job-name {{name}}
              .job-schedule {{schedule}}
              .job-description {{description}}
            .job-actions
              button.js-pause-job.btn.btn-sm.btn-warning(data-job-id="{{_id}}") {{_ 'pause'}}
              button.js-delete-job.btn.btn-sm.btn-danger(data-job-id="{{_id}}") {{_ 'delete'}}
        .add-job-section
          button.js-add-cron-job.btn.btn-success {{_ 'add-cron-job'}}

template(name="cronMigrations")
  .cron-migrations
    .migration-header
      h2
        | 🗄️
        | {{_ 'database-migrations'}}
      .migration-controls
        button.btn.btn-primary.js-start-all-migrations
          | ▶️
          | {{_ 'start-all-migrations'}}
        button.btn.btn-warning.js-pause-all-migrations
          | ⏸️
          | {{_ 'pause-all-migrations'}}
        button.btn.btn-danger.js-stop-all-migrations
          | ⏹️
          | {{_ 'stop-all-migrations'}}
    
    .migration-progress
      .progress-overview
        .progress-bar
          .progress-fill(style="width: {{migrationProgress}}%") 
        .progress-text {{migrationProgress}}%
        .progress-label {{_ 'overall-progress'}}
      
      .current-step
        | ⚙️
        | {{migrationCurrentStep}}
      
      .migration-status
        | ℹ️
        | {{migrationStatus}}
    
    .migration-steps
      h3 {{_ 'migration-steps'}}
      .steps-list
        each migrationSteps
          .migration-step(class="{{#if completed}}completed{{/if}}" class="{{#if isCurrentStep}}current{{/if}}")
            .step-header
              .step-icon
                if completed
                  | ✅
                else if isCurrentStep
                  | ⚙️
                else
                  | ⭕
              .step-info
                .step-name {{name}}
                .step-description {{description}}
              .step-progress
                if completed
                  .progress-text 100%
                else if isCurrentStep
                  .progress-text {{progress}}%
                else
                  .progress-text 0%
            if isCurrentStep
              .step-progress-bar
                .progress-fill(style="width: {{progress}}%")

template(name="cronBoardOperations")
  .cron-board-operations
    .board-operations-header
      h2
        | 📋
        | {{_ 'board-operations'}}
      .board-operations-controls
        button.btn.btn-success.js-refresh-board-operations
          | 🔄
          | {{_ 'refresh'}}
        button.btn.btn-primary.js-start-test-operation
          | ▶️
          | {{_ 'start-test-operation'}}
        button.btn.btn-info.js-force-board-scan
          | 🔍
          | {{_ 'force-board-scan'}}
    
    .board-operations-stats
      .stats-grid
        .stat-item
          .stat-value {{operationStats.total}}
          .stat-label {{_ 'total-operations'}}
        .stat-item
          .stat-value {{operationStats.running}}
          .stat-label {{_ 'running'}}
        .stat-item
          .stat-value {{operationStats.completed}}
          .stat-label {{_ 'completed'}}
        .stat-item
          .stat-value {{operationStats.error}}
          .stat-label {{_ 'errors'}}
        .stat-item
          .stat-value {{queueStats.pending}}
          .stat-label {{_ 'pending'}}
        .stat-item
          .stat-value {{queueStats.maxConcurrent}}
          .stat-label {{_ 'max-concurrent'}}
        .stat-item
          .stat-value {{boardMigrationStats.unmigratedCount}}
          .stat-label {{_ 'unmigrated-boards'}}
        .stat-item
          .stat-value {{boardMigrationStats.isScanning}}
          .stat-label {{_ 'scanning-status'}}
    
    .system-resources
      .resource-item
        .resource-label {{_ 'cpu-usage'}}
        .resource-bar
          .resource-fill(style="width: {{systemResources.cpuUsage}}%")
        .resource-value {{systemResources.cpuUsage}}%
      .resource-item
        .resource-label {{_ 'memory-usage'}}
        .resource-bar
          .resource-fill(style="width: {{systemResources.memoryUsage}}%")
        .resource-value {{systemResources.memoryUsage}}%
      .resource-item
        .resource-label {{_ 'cpu-cores'}}
        .resource-value {{systemResources.cpuCores}}
    
    .board-operations-search
      .search-box
        input.form-control.js-search-board-operations(type="text" placeholder="{{_ 'search-boards-or-operations'}}")
        | 🔍.search-icon
    
    .board-operations-list
      .operations-header
        h3 {{_ 'board-operations'}} ({{pagination.total}})
        .pagination-info
          | {{_ 'showing'}} {{pagination.start}} - {{pagination.end}} {{_ 'of'}} {{pagination.total}}
      
      .operations-table
        table.table.table-striped
          thead
            tr
              th {{_ 'board-id'}}
              th {{_ 'operation-type'}}
              th {{_ 'status'}}
              th {{_ 'progress'}}
              th {{_ 'start-time'}}
              th {{_ 'duration'}}
              th {{_ 'actions'}}
          tbody
            each boardOperations
              tr
                td
                  .board-id {{boardId}}
                td
                  .operation-type {{operationType}}
                td
                  span.status-badge(class="status-{{status}}") {{status}}
                td
                  .progress-container
                    .progress-bar
                      .progress-fill(style="width: {{progress}}%")
                    .progress-text {{progress}}%
                td {{formatDateTime startTime}}
                td {{formatDuration startTime endTime}}
                td
                  .btn-group
                    if isRunning
                      button.btn.btn-sm.btn-warning.js-pause-operation(data-operation="{{id}}")
                        | ⏸️
                    else
                      button.btn.btn-sm.btn-success.js-resume-operation(data-operation="{{id}}")
                        | ▶️
                    button.btn.btn-sm.btn-danger.js-stop-operation(data-operation="{{id}}")
                      | ⏹️
                    button.btn.btn-sm.btn-info.js-view-details(data-operation="{{id}}")
                      | ℹ️
      
      .pagination
        if pagination.hasPrev
          button.btn.btn-sm.btn-default.js-prev-page
            | ◀️
            | {{_ 'previous'}}
        .page-info
          | {{_ 'page'}} {{pagination.page}} {{_ 'of'}} {{pagination.totalPages}}
        if pagination.hasNext
          button.btn.btn-sm.btn-default.js-next-page
            | {{_ 'next'}}
            | ▶️

template(name="cronJobs")
  .cron-jobs
    .jobs-header
      h2
        | ⏰
        | {{_ 'cron-jobs'}}
      .jobs-controls
        button.btn.btn-success.js-refresh-jobs
          | 🔄
          | {{_ 'refresh'}}
    
    .jobs-list
      table.table.table-striped
        thead
          tr
            th {{_ 'job-name'}}
            th {{_ 'schedule'}}
            th {{_ 'status'}}
            th {{_ 'last-run'}}
            th {{_ 'next-run'}}
            th {{_ 'actions'}}
        tbody
          each cronJobs
            tr
              td {{name}}
              td {{schedule}}
              td
                span.status-badge(class="status-{{status}}") {{status}}
              td {{formatDate lastRun}}
              td {{formatDate nextRun}}
              td
                .btn-group
                  if isRunning
                    button.btn.btn-sm.btn-warning.js-pause-job(data-job="{{name}}")
                      | ⏸️
                  else
                    button.btn.btn-sm.btn-success.js-start-job(data-job="{{name}}")
                      | ▶️
                  button.btn.btn-sm.btn-danger.js-stop-job(data-job="{{name}}")
                    | ⏹️
                  button.btn.btn-sm.btn-danger.js-remove-job(data-job="{{name}}")
                    | 🗑️

template(name="cronAddJob")
  .cron-add-job
    .add-job-header
      h2
        | ➕
        | {{_ 'add-cron-job'}}
    
    .add-job-form
      form.js-add-cron-job-form
        .form-group
          label(for="job-name") {{_ 'job-name'}}
          input.form-control#job-name(type="text" name="name" required)
        
        .form-group
          label(for="job-description") {{_ 'job-description'}}
          textarea.form-control#job-description(name="description" rows="3")
        
        .form-group
          label(for="job-schedule") {{_ 'schedule'}}
          select.form-control#job-schedule(name="schedule")
            option(value="every 1 minute") {{_ 'every-1-minute'}}
            option(value="every 5 minutes") {{_ 'every-5-minutes'}}
            option(value="every 10 minutes") {{_ 'every-10-minutes'}}
            option(value="every 30 minutes") {{_ 'every-30-minutes'}}
            option(value="every 1 hour") {{_ 'every-1-hour'}}
            option(value="every 6 hours") {{_ 'every-6-hours'}}
            option(value="every 1 day") {{_ 'every-1-day'}}
            option(value="once") {{_ 'run-once'}}
        
        .form-group
          label(for="job-weight") {{_ 'weight'}}
          input.form-control#job-weight(type="number" name="weight" value="1" min="1" max="10")
        
        .form-actions
          button.btn.btn-primary(type="submit")
            | ➕
            | {{_ 'add-job'}}
          button.btn.btn-default.js-cancel-add-job
            | ❌
            | {{_ 'cancel'}}
